package com.jml.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;


/**
 * 配置RedissonConfig配置
 */
@Configuration
public class RedissonConfig {
    @Value("${spring.redis.host}")
    private String host;
    @Value("${spring.redis.port}")
    private String port;

    @Bean("redissonClient1")
    @Primary
    public RedissonClient getRedisson1() {
        Config config = new Config();
        //设置看门狗时间 续命线程定时间隔时间
//        config.setLockWatchdogTimeout(100000000);
        //设置单机版本redis
        config.useSingleServer().setAddress("redis://" + host + ":" + port);
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }

    @Bean("redissonClient2")
    public RedissonClient getRedisson2() {
        Config config = new Config();
        //设置看门狗时间 续命线程定时间隔时间
//        config.setLockWatchdogTimeout(100000000);
        //设置单机版本redis
        config.useSingleServer().setAddress("redis://127.0.0.1:6380");
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }

    @Bean("redissonClient3")
    public RedissonClient getRedisson3() {
        Config config = new Config();
        //设置看门狗时间 续命线程定时间隔时间
//        config.setLockWatchdogTimeout(100000000);
        //设置单机版本redis
        config.useSingleServer().setAddress("redis://127.0.0.1:6381");
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }

}